package com.jianguozh.difs.support.service.listener;

import com.jianguozh.difs.support.service.component.file.core.FileClientManager;
import com.jianguozh.difs.support.service.component.file.core.client.DefaultFileClientSetting;
import com.jianguozh.difs.support.service.event.FileClientConfigSucceedEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 文件客户端配置更新成功监听
 * @author hanrs
 * @email 4076130@qq.com
 * @since 2022/7/14 11:25
 */
@Component
public class FileClientConfigSucceedListener {

    @Autowired
    FileClientManager fileClientManager;

    @Async
    @Order
    @EventListener(FileClientConfigSucceedEvent.class)
    public void update(FileClientConfigSucceedEvent event) {
        DefaultFileClientSetting clientSetting = (DefaultFileClientSetting) event.getSource();
        fileClientManager.updateFileClient(clientSetting);
    }
}
